import {getNotNull,dealStartEndDate} from '@/views/util'
import {PROJECT_DIC} from '@/const/dict'
export default function () {
  return {
    data() {
      return {
        detailData:[]
      }
    },
    methods: {
      // 获取规划详情
      getDetailDataMins(records){
        var supportDeptName = '';
        if(records.supportDeptName){
          supportDeptName = records.supportDeptName
        }else{
          if(records.supportDeptNameList && records.supportDeptNameList.length>0){
            for(var i in records.supportDeptNameList){
              supportDeptName += records.supportDeptNameList[i] + ','
            }
          }
        }
        this.detailData = [
          {label:'规划名称',value:getNotNull(records.title)},
          {label:'规划类型',value:getNotNull(records.category,PROJECT_DIC.CATEGORY),newline:true},
          {label:'规划期限',value: dealStartEndDate(records.startDate,records.endDate),newline:true},
          {label:'申报(牵头)单位',value:getNotNull(records.orgName),newline:true},
          {label:'协同编制部门',value:getNotNull(supportDeptName),newline:true},
          {label:'发布层级',value:getNotNull(records.planningLevel,PROJECT_DIC.PLANNING_LEVEL),newline:true},
          {label:'发布时间',value:getNotNull(records.releaseDate,null,'date'),newline:true},
          {label:'审批机关级别',value:getNotNull(records.approvingAuthorityLevel,PROJECT_DIC.APPROVING_AUTHORITY_LEVEL),newline:true},
          {label:'审批机关性质',value:getNotNull(records.approvingAuthorityNature,PROJECT_DIC.APPROVING_AUTHORITY_NATURE),newline:true},
          {label:'联系人姓名',value:getNotNull(records.contactName),newline:true},
          {label:'联系电话',value:getNotNull(records.contactNumber),newline:true},
          {label:'规划等级',value:getNotNull(records.planningRank,PROJECT_DIC.PLANNING_RANK)},
          {label:'编制经费来源',value:getNotNull(records.financialSource)},
          {label:'立项依据',value:getNotNull(records.basis),fileName:records.basisFileId,type:'basis'},
          // {label:'规划范围',value:getNotNull(records.scope)},
          {label:'主要内容',value:getNotNull(records.content)},
          {label:'相关材料',fileName:this.multiplefiles,type:'related'}
        ]
      },
      // 获取成果详情
      getresultDetailDate(records){
        this.detailData = [
          {label:'文号',value:getNotNull(records.releaseNo)},
          {label:'规划名称',value:getNotNull(records.title)},
          {label:'规划类型',value:getNotNull(records.category,PROJECT_DIC.CATEGORY),newline:true},
          {label:'规划期限',value: dealStartEndDate(records.startDate,records.endDate),newline:true},
          {label:'申报(牵头)单位',value:getNotNull(records.orgName),newline:true},
          {label:'规划等级',value:getNotNull(records.planningRank,PROJECT_DIC.PLANNING_RANK),newline:true},
          {label:'发布时间',value:getNotNull(records.releaseDate,null,'date'),newline:true},
          {label:'发布层级',value:getNotNull(records.planningLevel,PROJECT_DIC.PLANNING_LEVEL),newline:true},

          {label:'审批机关级别',value:getNotNull(records.approvingAuthorityLevel,PROJECT_DIC.APPROVING_AUTHORITY_LEVEL),newline:true},
          {label:'审批机关性质',value:getNotNull(records.approvingAuthorityNature,PROJECT_DIC.APPROVING_AUTHORITY_NATURE),newline:true},
          {label:'联系人姓名',value:getNotNull(records.contactName),newline:true},
          {label:'联系电话',value:getNotNull(records.contactNumber),newline:true},

          {label:'编制经费来源',value:getNotNull(records.financialSource)},
          {label:'立项依据',value:getNotNull(records.basis),fileName:records.basisFileId,type:'basis'},

          {label:'主要内容',value:getNotNull(records.content)},
          {label:'规划文本',fileName:records.textId,type:'text'},
          {label:'相关材料',fileName:this.multiplefiles,type:'related'},
          {label:'是否公开',value:getNotNull(records.isOpen,PROJECT_DIC.isOpen,'isOpen')},
        ];
        if(records.state == '0'){
          this.detailData = this.detailData.map((v, index) => {
            if (v.label === '规划类型') {
              return {
                label: '(拟申报)规划类型',
                value: v.value,
                newline:true
              }
            }
            if (v.label === '发布时间') {
              return {
                label: '(拟)发布时间',
                value: v.value,
                newline:true
              }
            }
            if (v.label === '发布层级') {
              return {
                label: '(拟)发布层级',
                value: v.value,
                newline:true
              }
            }
            return v;
          })
        }
      },
    }
  }
}
